import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Window 2.0
import QtQuick.Dialogs 1.0
import QtQuick.XmlListModel 2.0
import QtQuick.Controls.Styles 1.0


Rectangle {

    id: paneCharacterEdit
    color: "lightsteelblue"

    Item {
        anchors.fill: parent
        anchors.margins: 6

        Item {
            id: itemTitle
            anchors.top: parent.top
            anchors.left: parent.left
            anchors.right: parent.right
            height: 20

            ComponentButton {
                id: buttonRemove
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: undefined
                horizontalAlignment: Qt.AlignHCenter
                text: "-"
                width: 20

            }

            ComponentButton {
                id: buttonAdd
                anchors.right: buttonRemove.left
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: undefined
                anchors.leftMargin: 6
                anchors.rightMargin: 6
                horizontalAlignment: Qt.AlignHCenter
                text: "+"
                width: 20
            }



            Text {
                id: textEditTitle
                text: "Character Class"
                color: "white"
                anchors.left: parent.left
                anchors.right: buttonAdd.left
                anchors.verticalCenter: parent.verticalCenter
                font.pixelSize: 16
                font.bold: true
                clip: true
            }
        }

        Column {
            id: columnCharacterName
            anchors.top: itemTitle.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Name"

                color: "white"
                font.bold: true;
            }

            Rectangle {
                anchors.left: parent.left
                anchors.right: parent.right
                height: 20

                color: "white"

                TextInput {
                    text: characterClassesModel.get(editIndex).name
                    anchors.fill: parent
                    verticalAlignment: TextInput.AlignVCenter
                    anchors.margins: 3
                }
            }
        }

        Column {
            id: columnHitDie
            anchors.top: columnCharacterName.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Hit Die"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelHitDice
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).hitDie

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Column {
            id: columnSkillPoints
            anchors.top: columnHitDie.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Skill Points"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelSkillPoints
                textRole: "skillPointName"
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).skillPoints

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Column {
            id: columnBaseAttack
            anchors.top: columnSkillPoints.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Base Attack Bonus"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelBaseBonus
                textRole: "baseBonusName"
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).baseAttack

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Column {
            id: columnFortSave
            anchors.top: columnBaseAttack.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Fortitude Save"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelSaveBonus
                textRole: "saveBonusName"
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).fortSave

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Column {
            id: columnRefSave
            anchors.top: columnFortSave.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Reflex Save"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelSaveBonus
                textRole: "saveBonusName"
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).refSave

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Column {
            id: columnWillSave
            anchors.top: columnRefSave.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.margins: 2
            anchors.topMargin: 8
            spacing: 6

            Text {
                text: "Willpower Save"

                color: "white"
                font.bold: true;
            }

            ComboBox {
                model: modelSaveBonus
                textRole: "saveBonusName"
                anchors.left: parent.left
                anchors.right: parent.right
                currentIndex: characterClassesModel.get(editIndex).willSave

                onCurrentIndexChanged: {
                        /// \todo Replace XmlListModel with real data model, since XmlListModel is read only!
                        /// \author Jussi
                        /// \date 2013-10-11
                }
            }
        }

        Item {
            id: columnSpecialAbilities
            anchors.top: columnWillSave.bottom
            anchors.left: parent.left
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.margins: 2
            anchors.topMargin: 8

            Text {
                id: textSpecialAbilitiesTitle
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.top

                text: "Special Abilities"

                color: "white"
                font.bold: true;
            }

            ScrollView {
                anchors.top: textSpecialAbilitiesTitle.bottom
                anchors.left: parent.left
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                anchors.topMargin: 6

                ListView {
                    model: specialAbilitiesModel
                    spacing: 4
                    delegate: Row {
                        anchors.left: parent.left
                        anchors.right: parent.right
                        spacing: 6

                        Text {
                            color: "white"
                            text: specialAbilityName
                            width: 120
                        }

                        Text {
                            color: "white"
                            text: specialAbility.multiple ? "(multiple)" : ""
                        }
                    }
                }
            }


        } // columnSpecialAbilities
    }

}
